//
//  FileManager.m
//  Core
//
//  Created by Cuong Doan on 3/7/13.
//  Copyright (c) 2013 Cuong Doan. All rights reserved.
//

#import "FileManager.h"

@implementation FileManager

+(BOOL)checkDocumentFile:(NSString *)FileName
{
    @autoreleasepool
    {
        NSFileManager *fileManager = [NSFileManager defaultManager];
        
        NSString *documentPath = [self getDocumentPath:FileName];
        
        BOOL existed = [fileManager fileExistsAtPath:documentPath];
        
        return existed;
    }
}

+(void)saveFileToDocument:(NSString *)FileName
{
    @autoreleasepool
    {
        NSError *error = nil;
        
        NSFileManager *fileManager = [NSFileManager defaultManager];
        
        NSString *resourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FileName];
        
        NSString *documentPath = [self getDocumentPath:FileName];
        
        [fileManager copyItemAtPath:resourcePath toPath:documentPath error:&error];
    }
}

+(NSString *)getDocumentPath:(NSString *)FileName
{
    @autoreleasepool
    {
        NSString *documentPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:FileName];
        
        return documentPath;
    }
}

@end
